<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    手机号：<input type="text"> <button>获取验证码</button>

    <script>
        //需要倒计时的60秒
        let time = 3;
        const btnObj = document.querySelector("button")
        btnObj.addEventListener("click",function(){
            this.disabled = true;
            //设置一个定时效果
            const setInterval1 = setInterval(function(){
                if(time!=0){
                    time--;
                    btnObj.innerText = '等待'+time+"秒可以再次点击"
                }else{
                    //取消定时器
                    console.log(this)
                    clearInterval(setInterval1)
                    btnObj.disabled = false;
                    btnObj.innerText = '获取验证码'
                    time =3;
                }
            },1000)
        })
    </script>
</body>
</html>